package com.systop.party05.utils;

import android.content.Context;
import android.provider.Settings;
import android.telephony.TelephonyManager;

/**
 * Created by Administrator on 2016/7/13.
 */
public class GeneralTools {

    //设备ID 获取 android7.0关于TelephonyManager.getDeviceId()返回null的问题
    public static String getDeviceId(Context context) {
        String id="";
        //android.telephony.TelephonyManager
        try {
            TelephonyManager mTelephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
            if (mTelephony.getDeviceId() != null) {
                id = mTelephony.getDeviceId();
            } else {
                //android.provider.Settings;
                id = Settings.Secure.getString(context.getApplicationContext().getContentResolver(), Settings.Secure.ANDROID_ID);
            }
        }catch (SecurityException e){
            e.printStackTrace();
        }
        return id;
    }
}
